package james.edu.db;

import james.edu.to.FlashCardTO;

import java.util.List;

import org.springframework.dao.DataAccessException;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;


public class HSQLFlashCardDaoImpl extends HibernateDaoSupport
 implements FlashCardDao{
	

	public void save(FlashCardTO flashCard) {
		this.getHibernateTemplate().save(flashCard);
	}
	
	public void update(FlashCardTO flashCard) {
		this.getHibernateTemplate().update(flashCard);
	}
	
	public void archive(FlashCardTO flashCard){
		flashCard.setInactive(true);
		this.getHibernateTemplate().update(flashCard);
	}
	
	public List getAll(){
        return this.getHibernateTemplate().find(
                "from james.edu.to.FlashCardTO ");
        }
	
	public List getAllActive()throws DataAccessException {
        return this.getHibernateTemplate().find(
                "from james.edu.to.FlashCardTO flashCard where flashCard.inactive=0");
        }

	
	public void insert(FlashCardTO flashCard){
		this.getHibernateTemplate().persist(flashCard);
	}
}
